home *** CD-ROM | disk | FTP | other *** search
- Path: gryphon.phoenix.net!usenet
- From: brucew@phoenix.net (Bruce Wedding)
- Newsgroups: comp.lang.c
- Subject: Re: Problem with c code, please help!
- Date: Sun, 21 Jan 1996 04:56:26 GMT
- Organization: BranPaul Systems
- Message-ID: <4dseo8$19n@gryphon.phoenix.net>
- References: <surgsw-1901960148530001@128.206.206.86> <mikedorman-1901960725380001@205.148.200.150> <PRYE.96Jan20020251@ub239.dialup.uwa.edu.au>
- NNTP-Posting-Host: dial129.phoenix.net
- X-Newsreader: Moe's Newsreader
-
- prye@cyllene.uwa.edu.au (Peter Rye) wrote:
-
- >> char *word;
- >>
- >> puts("Enter a word: ");
- >> while(scanf("%s", word) != 0)
-
- >I'm not sure that this is good advice.
-
- Then let me assure you, it is lousy advice. He is assigning
- a string to a pointer that is not only unitialized, but also
- doesn't point to any memory that he owns. If you do it this
- way, you have to allocate memory. And I would advise him
- to lose scanf also. Use the tried and true combination of
- fgets() and sscanf()
-
-
- Bruce D. Wedding Have Compiler, Will Travel!
- Perspicacious Programming Performed Promptly
- Katy, Texas, USA, Planet Earth, Milkyway Galaxy, Known Universe
-
-